
web_lines = [
    ["打开浏览器", "openbroswer"],
    ["打开被测网站", "openurl", 'http://192.168.0.103/index.php'],
    ["点击登录链接", "click", '//a[text()="登录"]'],
    ["输入用户名", "input", 'username','13800138006'],
    ["输入密码", "input", 'password','123456'],
    ["输入验证码", "input", 'verify_code','1111'],
    ["点击登录按钮", "click", '[name="sbtbutton"]'],
    ["点击登录按钮", "click", '[name="sbtbutton"]'],
    ["输入要搜索的数据", "input", 'q', '手机'],
    ["点击搜索按钮", "click", '[class="search_usercenter_btn"]'],
    ["点击HUAWEI手机,进入商品详情", "click", '//a[contains(text(), "HUAWEI")]'],

]

inter_lines = [[]]

def run(obj, line):
    """反射获取关键字函数, 并执行"""
    func = getattr(obj, line[1])
    params = line[2:] # 参数数据
    func(*params) # 执行反射调用的函数, 并传入参数

from common.webkeys import Web
from common.inter_keys import HTTP
from test_tools.class_excel import Writer

writer = Writer()

web = Web()
http = HTTP(writer)

case_type = input('请输入要执行的自动化类型: ')

if case_type == "inter":
    for line in inter_lines:
        run(http, line)

elif case_type == "web":
    for line in web_lines:
        run(web, line)
else:
    for line in inter_lines:
        run(http, line)
    for line in web_lines:
        run(web, line)


